# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=dublin-traceroute
pkgver=348.ea3a974
pkgrel=1
pkgdesc='NAT-aware multipath tracerouting tool.'
arch=('any')
groups=('blackarch' 'blackarch-networking')
url='https://github.com/insomniacslk/dublin-traceroute'
license=('BSD')
depends=('jsoncpp' 'libtins' 'libpcap' 'gtest')
makedepends=('cmake' 'git' 'libcap')
source=("git+https://github.com/insomniacslk/$pkgname.git"
        'CMakeLists.txt.patch')
sha512sums=('SKIP'
            '2d3b0b0286edb4fc56d203c17477710a7b9ab469a254401448501f58f268737d0a3ab1e967868d0a32b8728c4bfda38816edbbe6a2620bab96176abd014c55f4')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  patch -p1 < CMakeLists.txt.patch
}

build() {
  cd "$pkgname"

  mkdir -p build
  cd build
  cmake -DCMAKE_INSTALL_PREFIX=/usr ..
  make
}

package() {
  cd "$pkgname/build"

  make DESTDIR="$pkgdir" install
  setcap cap_net_raw+ep "$pkgdir/usr/bin/$pkgname"

  cd ..

  install -Dm 644 COPYING "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf "$pkgdir/usr/include/"{gmock,gtest} "$pkgdir/usr/lib/"{cmake,pkgconfig}
}

